﻿using KingerRobot.MexicoSailunMDC.Dao;
using System.ComponentModel.DataAnnotations.Schema;

namespace KingerRobot.MexicoSailunMDC.Spi;
public class GetCuringByCuringIdsRefCuringResult
{

    public List<CuringCallMaterialResult> curingList { get; set; }

    public string msg { get; set; }

    public int status { get; set; }
}

public class ResultMes
{
    public ResultMes(string msg, int status)
    {
        this.msg = msg;
        this.status = status;
    }

    public string msg { get; set; }

    public int status { get; set; }
}

/// <summary>
/// 硫化机服务
/// </summary>
public interface ICuringService
{
    /// <summary>
    /// 同步请料数据
    /// </summary>
    /// <param name="syncRequestMaterialBeans"></param>
    /// <returns></returns>
    void MesSyncRequestMaterial(List<SyncRequestMaterialBean> syncRequestMaterialBeans);
    /// <summary>
    /// 通过硫化Id 获取硫化机请料方式
    /// </summary>
    /// <param name="curingLocIds"></param>
    /// <returns></returns>
    List<CuringCallNo> GetCuringByCuringIdsRefCuring(List<long> curingLocIds);
    /// <summary>
    /// 查找执行异常的Ems小车
    /// </summary>
    /// <param name="materialBeans"></param>
    /// <returns></returns>
    GetCuringByCuringIdsRefCuringResult RequestMaterial(List<RequestMaterialBean> materialBeans);
    /// <summary>
    /// 按条码请料
    /// </summary>
    /// <param name="materialBeans"></param>
    /// <returns></returns>
    ResultMes RequestMaterialByBarcode(List<RequestMaterialByBarcodeBean> materialBeans);
    /// <summary>
    /// 按规格、数量请料
    /// </summary>
    /// <param name="materialBeans"></param>
    /// <returns></returns>
    GetCuringByCuringIdsRefCuringResult RequestMaterialByMaterial(List<RequestMaterialByMaterialBean> materialBeans);
    /// <summary>
    /// 按中间表(硫化机台状态)请料
    /// </summary>
    List<CuringCallMaterialResult> RequestMaterialByMiddleTable(List<RequestMaterialBean> materialBeans);
    /// <summary>
    /// 修改安全信号
    /// </summary>
    /// <param name="targetLoc"></param>
    /// <param name="safe"></param>
    /// <returns></returns>
    int UpdateOrderSummarySafe(long targetLoc, int safe);
    /// <summary>
    /// 添加安全信号
    /// </summary>
    /// <param name="summaryId"></param>
    /// <param name="targetLoc"></param>
    /// <param name="safe"></param>
    /// <returns></returns>
    int AddOrderSafe(long summaryId, long targetLoc, int safe);
    /// <summary>
    /// 获取安全信号
    /// </summary>
    /// <param name="targetLoc"></param>
    /// <returns></returns>
    BarCodeSafe GetOrderSafe(long targetLoc);
    /// <summary>
    /// 修改
    /// </summary>
    /// <param name="targetLoc"></param>
    /// <returns></returns>
    int UpdateSafe(long targetLoc);
    /// <summary>
    /// 获取硫化机编号 和 左右模
    /// </summary>
    /// <param name="taskNo"></param>
    /// <returns></returns>
    CuringBean GetCuringMode(int taskNo);

    /// <summary>
    /// 生产 添加 请料完成
    /// </summary>
    /// <param name="curingBean"></param>
    /// <returns></returns>
    int AddCuringBean(CuringBean curingBean);
    /// <summary>
    /// 出库完成 临时位置
    /// </summary>
    /// <param name="curingBean"></param>
    /// <returns></returns>
    int AddOutWarehouse(CuringBean curingBean);
    /// <summary>
    /// 获取完成绑定条码
    /// </summary>
    /// <param name="targetLoc"></param>
    /// <returns></returns>
    BarCodeLoc GetBarCodeByLoc(long targetLoc);

    int UpdateMesCuringNorm(MesCuringNormBean curingNorm);

    int DeleteMesCuringNormByStatus(int ststus);

    int UpdateMesCuringNormByStatus(int ststus);

    POWcsManualCuringRecord GetFirstManualCuringRecordDesc();

    int AddManualCuringRecordByProductCode(string curingModelCode, string productCode, DateTime? mesPutTime);

}

/// <summary>
/// 人工放胎类
/// </summary>
public class ManualPlacementCuring
{
    public long CuringCode { get; set; }
    public long LocId { get; set; }

    public string LocName { get; set; }

    public long SummaryId { get; set; }
    public long TaskId { get; set; }
    public int Stock { get; set; }
    /// <summary>
    /// 当前ems状态 正常 报警信息 禁用 手动
    /// </summary>
    public string EmsStatus { get; set; }

    public string CrnStatus { get; set; }
}


/// <summary>
/// 硫化机请料流水号
/// </summary>
public class CuringCallNo
{
    /// <summary>
    /// 设备ID
    /// </summary>
    public long EquipId { get; set; }
    /// <summary>
    /// 位置ID
    /// </summary>
    public long LocId { get; set; }
    /// <summary>
    /// 硫化机请料，上次流水号
    /// </summary>
    public int CallNo { get; set; }
    /// <summary>
    /// 是否硫化机清料：1 是；0 Mes 中间表请料；3、流水号请料
    /// </summary>
    public int CallSign { get; set; }

}

/// <summary>
/// 条码对象
/// </summary>
public class BarCodeLoc
{
    /// <summary>
    /// 序号
    /// </summary>
    public int Num { get; set; }
    /// <summary>
    /// 条码
    /// </summary>
    public string BarCode { get; set; }
}
/// <summary>
/// 安全信号
/// </summary>
public class BarCodeSafe
{
    /// <summary>
    /// 返回值
    /// </summary>
    public int Num { get; set; }
    /// <summary>
    /// 安全信号
    /// </summary>
    public int Safe { get; set; }
}
/// <summary>
/// 硫化机对象
/// </summary>
public class CuringBean
{
    /// <summary>
    /// 条码
    /// </summary>
    public string BarCode { get; set; }
    /// <summary>
    /// 硫化机编号
    /// </summary>
    // public string CuringCode { get; set; }
    /// <summary>
    /// 左右模
    /// </summary>
    public string Mode { get; set; }
    /// <summary>
    /// 是否喷涂
    /// </summary>
    // public bool Spray { get; set; }
    /// <summary>
    /// 作业指示编号
    /// </summary>
    // public string Serno { get; set; }
}
/// <summary>
/// 请料对象
/// </summary>
public class RequestMaterialBean
{
    public string Id { get; set; }
    /// <summary>
    /// 设备位置
    /// </summary>
    public long CuringLocId { get; set; }
    /// <summary>
    /// 设备ID
    /// </summary>
    public long CuringEquipId { get; set; }
    /// <summary>
    /// 硫化设备代码
    /// </summary>
    public string CuringCode { get; set; }
    /// <summary>
    /// 作业指示编号
    /// </summary>
    public string Serno { get; set; }
    /// <summary>
    /// Spec 码
    /// </summary>
    public string Spec { get; set; }
    /// <summary>
    /// 左右模
    /// </summary>
    public int? CuringMode { get; set; }
    /// <summary>
    /// 左右请物料规格
    /// </summary>
    public string MaterialCode { get; set; }
    /// <summary>
    /// 左模旋转
    /// </summary>
    public string Angle { get; set; }
    /// <summary>
    /// 请料数量
    /// </summary>
    public decimal? InvQty { get; set; }
    /// <summary>
    /// 还可以请料数量
    /// </summary>
    public int? CanQty { get; set; }
    /// <summary>
    /// 是否硫化机清料：1 是；0 Mes 中间表请料；2、流水号请料
    /// </summary>
    public int CallSign { get; set; }
    /// <summary>
    /// 上次请料流水号
    /// </summary>
    public int CallNo { get; set; }
    public string Remark { get; set; }
}
/// <summary>
/// 请料对象
/// </summary>
public class SyncRequestMaterialBean
{
    /// <summary>
    /// 硫化机编号
    /// </summary>
    public string EquipNo { get; set; }
    /// <summary>
    /// 硫化机左右模
    /// </summary>
    public int? EquipModel { get; set; }
    /// <summary>
    /// 物料Id
    /// </summary>
    public string MaterialId { get; set; }
    /// <summary>
    /// 物料编号
    /// </summary>
    public string MaterialCode { get; set; }
    /// <summary>
    /// 最大缓存数量
    /// </summary>
    public int? MaxCacheCount { get; set; }
    /// <summary>
    /// 当前缓存数量
    /// </summary>
    public int? RealCacheCount { get; set; }
    /// <summary>
    /// 更新时间（单位秒）
    /// </summary>
    public int? CuringTime { get; set; }
    /// <summary>
    /// 当前胎胚开始硫化时间
    /// </summary>
    public DateTime? CurrentCuringTime { get; set; }
    /// <summary>
    /// 机台状态（MES）
    /// 1：正常
    /// 0：异常
    /// </summary>
    public int EquipStatusMes { get; set; }
    /// <summary>
    /// 机台状态（上位机）
    /// 1：正常
    /// 0：异常
    /// </summary>
    public int EquipStatusHost { get; set; }
    /// <summary>
    /// 单胎硫化时间
    /// </summary>
    public int CuringTotalTime { get; set; }
    /// <summary>
    /// 预硫化规格
    /// </summary>
    public string GreentyrenoMes { get; set; }
    /// <summary>
    /// 是否请料 0否1是
    /// </summary>
    public int IsEnableRequest { get; set; }

    public int HostWmsFlag { get; set; }
}

/// <summary>
/// 通过条码请料对象
/// </summary>
public class RequestMaterialByBarcodeBean
{
    /// <summary>
    /// 订单编号
    /// </summary>
    public string OrderNo { get; set; }
    /// <summary>
    /// 优先级
    /// </summary>
    public int OrderLevel { get; set; }
    /// <summary>
    /// 订单明细
    /// </summary>
    public List<RequestMaterialByBarcodeDetailBean> DetailBeans { get; set; }
}
/// <summary>
/// 通过订单明细请料对象
/// </summary>
public class RequestMaterialByBarcodeDetailBean
{
    /// <summary>
    /// 订单明细Id
    /// </summary>
    public string OrderDetailId { get; set; }
    /// <summary>
    /// 胎胚条码
    /// </summary>
    public string TireBarcode { get; set; }
    /// <summary>
    /// 硫化机编号
    /// </summary>
    public string EquipNo { get; set; }
    /// <summary>
    /// 硫化机左右模[1右; 2左]
    /// </summary>
    public int EquipModel { get; set; }
}

/// <summary>
/// 通过物料请料对象
/// </summary>
public class RequestMaterialByMaterialBean
{
    /// <summary>
    /// 订单编号
    /// </summary>
    public string OrderNo { get; set; }
    /// <summary>
    /// 优先级
    /// </summary>
    public int OrderLevel { get; set; }
    /// <summary>
    /// 订单明细
    /// </summary>
    public List<RequestMaterialByMaterialDetailBean> DetailBeans { get; set; }
}
/// <summary>
/// 通过物料明细请料对象
/// </summary>
public class RequestMaterialByMaterialDetailBean
{
    /// <summary>
    /// 订单明细Id
    /// </summary>
    public string OrderDetailId { get; set; }
    /// <summary>
    /// 物料id
    /// </summary>
    public string MaterialId { get; set; }
    /// <summary>
    /// 硫化机编号
    /// </summary>
    public string EquipNo { get; set; }
    /// <summary>
    /// 硫化机左右模
    /// </summary>
    public int EquipModel { get; set; }
    /// <summary>
    /// 请料数量
    /// </summary>
    public int OutputCount { get; set; }
}
public class MesCuringNormBean
{

    public string Greentyreno { get; set; }

    public decimal? Quantity { get; set; }
    /// <summary>
    /// 更新时间
    /// [ASRS_CURING_NORM_F_MES.UPDATETIME)]
    public DateTime? Updatetime { get; set; }
    /// <summary>
    /// 生产工位数 区分左右模
    /// [ASRS_CURING_NORM_F_MES.PRODUCERS)]
    /// </summary>
    public int? Producers { get; set; }
}